package com.zqxq.lottery.entity.o2o.user;

import com.zqxq.common.utils.DispatcherUtils;
import com.zqxq.lottery.entity.po.user.UserInfoPO;
import com.zqxq.lottery.entity.vo.user.UserInfoVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description ：
 * @Author ： 解风
 * @Date ： 2018/03/13 14:03
 */
public class UserInfoO2O {

    public static UserInfoVO toVO(UserInfoPO po) {
        if (po == null) {
            return null;
        }
        UserInfoVO userInfoVO = new UserInfoVO();
        userInfoVO.setUserId(DispatcherUtils.parseString(po.getId()));
        userInfoVO.setEquipmentId(po.getEquipment_id());
        userInfoVO.setPhoneModel(po.getPhone_model());
        userInfoVO.setMobile(po.getMobile());
        userInfoVO.setNickName(po.getNick_name());
        userInfoVO.setRealName(po.getReal_name());
        userInfoVO.setIdCard(po.getId_card());
        userInfoVO.setAge(DispatcherUtils.parseString(po.getAge()));
        userInfoVO.setSex(DispatcherUtils.parseString(po.getSex()));
        userInfoVO.setCity(po.getCity());
        userInfoVO.setSource(DispatcherUtils.parseString(po.getSource()));
        userInfoVO.setChannel(po.getChannel());
        userInfoVO.setLoginTime(DispatcherUtils.parseDateTimeStr(po.getLogin_time()));
        userInfoVO.setCreateTime(DispatcherUtils.parseDateTimeStr(po.getCreate_time()));
        userInfoVO.setUpdateTime(DispatcherUtils.parseDateTimeStr(po.getUpdate_time()));
        userInfoVO.setStatus(DispatcherUtils.parseString(po.getStatus()));
        return userInfoVO;
    }

    public static UserInfoPO toPO(UserInfoVO vo) {
        if (vo == null) {
            return null;
        }
        UserInfoPO userInfoPO = new UserInfoPO();
        userInfoPO.setId(DispatcherUtils.parseLong(vo.getUserId()));
        userInfoPO.setEquipment_id(vo.getEquipmentId());
        userInfoPO.setPhone_model(vo.getPhoneModel());
        userInfoPO.setMobile(vo.getMobile());
        userInfoPO.setNick_name(vo.getNickName());
        userInfoPO.setReal_name(vo.getRealName());
        userInfoPO.setId_card(vo.getIdCard());
        userInfoPO.setAge(DispatcherUtils.parseInteger(vo.getAge()));
        userInfoPO.setSex(DispatcherUtils.parseInteger(vo.getSex()));
        userInfoPO.setCity(vo.getCity());
        userInfoPO.setSource(DispatcherUtils.parseInteger(vo.getSource()));
        userInfoPO.setChannel(vo.getChannel());
        userInfoPO.setCreate_time(DispatcherUtils.parseDateTime(vo.getCreateTime()));
        userInfoPO.setUpdate_time(DispatcherUtils.parseDateTime(vo.getUpdateTime()));
        userInfoPO.setStatus(DispatcherUtils.parseInt(vo.getStatus()));
        return userInfoPO;
    }

    public static List<UserInfoVO> toVOList(List<UserInfoPO> poList){
        List<UserInfoVO> list = new ArrayList<UserInfoVO>();
        if(poList != null && poList.size() > 0){
            for (UserInfoPO po: poList) {
                list.add(toVO(po));
            }
        }
        return list;
    }
}
